const Service = require('egg').Service;

class OrderService extends Service {
	async getOrder() {
		const {
			app,
			ctx
		} = this;
		const {
			keyword
		} = ctx.query;
		let sql = `select * from orders where 1=1 `
		if (keyword) {
			sql += `and type like "%${keyword}%" `
		}
		const data = await app.mysql.query(sql)
		return data
	}
	async delOrder() {
		const {
			ctx,
			app
		} = this;
		const data = await app.mysql.delete('orders', {
			id: ctx.params.id
		}); // 根据id删除
		return data
	}
}

module.exports = OrderService;
